package pay

import (
	"strings"

	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/pay/bgw"
	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/pay/bspay"
	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/pay/uzpay"

	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/pay/base"
	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/pay/bcpay"
	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/pay/bpay"
	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/pay/bxpay"
	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/pay/easypay"
	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/pay/payfun"
	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/pay/paythere"
	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/pay/qqhfpay"
	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/pay/sojupay"
	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/pay/stanngpay"
	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/pay/starpay"
	"gitee.com/liuxuezhan/ar-platform/assets-api/internal/pay/tbpay"
)

type PayCode string

const (
	PayCodeTBPay     PayCode = "tbpay"
	PayCodeBxpay     PayCode = "bxpay"
	PayCodeBcpay     PayCode = "bcpay"
	PayCodePayfun    PayCode = "payfun"
	PayCodeRocket    PayCode = "rocket"
	PayCodeBkash     PayCode = "bkash"
	PayCodeSTARPay   PayCode = "starpay"
	PayCodeSojupay   PayCode = "sojupay"
	PayCodeQqhfPay   PayCode = "qqhfpay"
	PayCodeEasypay   PayCode = "easypay"
	PayCodeBpay      PayCode = "bpay"
	PayCodeLocalUsdt PayCode = "localusdt"
	PayStanNgPay     PayCode = "stanngpay"
	PayTherePay      PayCode = "paythere"
	UzPay            PayCode = "uzpay"
	BsPay            PayCode = "bspay"
	PayBgw           PayCode = "bgw"
)

// PayFactory 支付工厂接口
type PayFactory interface {
	CreatePay(config base.Config) base.Payment
}

func NewFactory(payType string, config base.Config) base.Payment {
	var factory PayFactory
	payCode := PayCode(strings.ToLower(payType))
	switch payCode {
	case PayCodeTBPay:
		factory = &tbpay.Factory{}
	case PayCodeBxpay:
		factory = &bxpay.Factory{}
	case PayCodeBcpay:
		factory = &bcpay.Factory{}
	case PayCodePayfun:
		factory = &payfun.Factory{}
	case PayCodeRocket:
		factory = &base.Factory{}
	case PayCodeLocalUsdt:
		factory = &base.Factory{}
	case PayCodeBkash:
		factory = &base.Factory{}
	case PayCodeSTARPay:
		factory = &starpay.Factory{}
	case PayCodeSojupay:
		factory = &sojupay.Factory{}
	case PayCodeQqhfPay:
		factory = &qqhfpay.Factory{}
	case PayCodeEasypay:
		factory = &easypay.Factory{}
	case PayCodeBpay:
		factory = &bpay.Factory{}
	case PayStanNgPay:
		factory = &stanngpay.Factory{}
	case PayTherePay:
		factory = &paythere.Factory{}
	case UzPay:
		factory = &uzpay.Factory{}
	case PayBgw:
		factory = &bgw.Factory{}
	case BsPay:
		factory = &bspay.Factory{}
	default:
		return nil
	}
	return factory.CreatePay(config)
}
